<!DOCTYPE html>
<#import "/common/common.html" as common>
<html>
<head>
	<@common.head title="微信wifi-登陆" keywords="" description="">
		<link href="${basePath}/res/css/login.css" rel="stylesheet">
		<script>
		  if(top.location!=self.location){
			  top.location = self.location;
		  }
		</script>
	</@common.head>
</head>

<body class="signin">
    <div class="signinpanel">
        <div class="row">
            <div class="col-sm-7">
                <div class="signin-info">
                    <div class="logopanel m-b">
                        <h1>[ 微信wifi管理系统 ]</h1>
                    </div>
                    <div class="m-b"></div>
                    <h4>欢迎使用 <strong>微信wifi管理系统 </strong></h4>
                    <!-- 
                    <ul class="m-b">
                        <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 优势一</li>
                        <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 优势二</li>
                        <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 优势三</li>
                        <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 优势四</li>
                        <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 优势五</li>
                    </ul>
                     -->
                    <strong>还没有账号？ <a href="#">立即注册&raquo;</a></strong>
                </div>
            </div>
            <div class="col-sm-5">
            	<form class="m-t" id="loginForm" role="form">
            		<h4 class="center-orientation">登录：</h4>
            		<div id="error" style="color:#A94442;height:10px;margin:5px 0px"></div>
	                <div class="form-group">
	                    <input type="text" name="username" class="form-control uname" placeholder="用户名" value="">
	                </div>
	                <div class="form-group">
	                    <input type="password" name="password" class="form-control pword" placeholder="密码" value="">
	                </div>
	                <!-- 
	                <div class="form-group">
	                    <input type="text" name="authCode" class="form-control code" placeholder="验证码" maxlength="4">
	                    <img id="authCodeImg" src="${basePath}/login/authCode" onclick="javascript:this.src='${basePath}/admin/login/authCode?rand=' + Math.random()" style="height: 34px;"/>
	                </div>
	                 -->
	                <a href="">忘记密码了？</a>
	                <button type="submit" class="btn btn-success btn-block">登 录</button>
	            </form>
            </div>
        </div>
        <div class="signup-footer">
            <div class="pull-left">
                &copy; 2015 <a href="http://www.zi-han.net/" target="_blank">金蜘蛛计算机信息技术有限公司 </a>
            </div>
        </div>
    </div>
    
    <script>
      //以下为官方示例
      $(function () {
    	  $("#loginForm input[name='username']").focus();
    	  
          // validate the loginForm form when it is submitted
          var icon = "<i class='fa fa-times-circle'></i> ";
          $("#loginForm").validate({
        	  rules: {
                  username: {
                      required: true,
                      minlength: 2
                  },
                  password: {
                      required: true
                  }
                  /*,
                  authCode: {
                      required: true,
                      minlength: 4,
                      maxlength: 4
                  }*/
              },
              messages: {
                  username: {
                      required: icon + "请输入您的用户名",
                      minlength: icon + "用户名必须两个字符以上"
                  },
                  password: {
                      required: icon + "请输入您的密码"
                  }
                  /*,
                  authCode: {
                      required: icon + "请输入验证码",
                      minlength: icon + "请输入4个字符的验证码",
                      maxlength: icon + "请输入4个字符的验证码"
                  }*/
              },
              submitHandler: function(form){
                 $(form).ajaxSubmit({
                	 url:"${basePath}/login/login",
                	 type:"post",
                	 dataType:"json",
                	 success: function (resp) {
                         if(resp.code == 0) {
                        	 window.location.href = "${basePath}/";
                         }else {
                         	if(resp.code == -1101) {
                        	 	$("#loginForm input[name='password']").val("");
                        	 	//$("#loginForm input[name='authCode']").val("");
                        	 	$("#loginForm input[name='password']").focus();
                         	}else if(resp.code == -1102){
                         		//$("#loginForm input[name='authCode']").val("");
                         		//$("#loginForm input[name='authCode']").focus();
                         	}
                         	if(resp.data != null) {
                         		$("#error").html(resp.data);
                         	}
                         	setTimeout("clearError()", 5000);
                       	 	//$("#authCodeImg").attr("src","${basePath}/login/authCode?rand=" + Math.random());
                         }
                     }
                 });
              },
              showErrors: function(errorMap, errorList) {
              		this.defaultShowErrors();
              }
          });
      });
      
      // 清空错误信息
      function clearError(){
    	  $("#error").empty();
      }
  </script>
</body>

</html>